/** @file oct_node.h
    @brief Octree node */

#ifndef G3_OCT_NODE_H
#define G3_OCT_NODE_H

#include "oct/oct_leaf.h"

namespace G3 {

/** @class OCT_NODE
    @brief An octree node class */
class OCT_NODE {
    public:
        /**
            @brief Constructor
        */
        OCT_NODE ();

        /**
            @brief Copy constructor
            @param[in] node Reference to the node to be copied
        */
        OCT_NODE (const OCT_NODE &node);

        /**
            @brief Destructor
        */
        ~OCT_NODE ();

        /** The 8 children of this node - nodes are positive, non-existent children are 0 and leaves are negative */
        int children [8];
        /** Bounding box of this node */
        G3::AABB3F BBox;

        /** Node-frustum visibility cache */
        G3::FRUSTUM_CLASSIFIC node_vis_cache;
        /** Pointer to the logger */
        G3::LOG *log;

        /**
            @brief Assignment operator
            @param[in] node Reference to the node to be assigned to this one
			@return Reference to the freshly assigned node
        */
        OCT_NODE &operator= (const OCT_NODE &node);

        /**
            @brief Clears the node
        */
        void clear ();

        /**
            @brief Dumps the node
        */
        void dump ();

        /**
            @brief Uploads the node
        */
        int upload (const std::vector<G3::OCT_NODE> &nodes, const std::vector<G3::OCT_LEAF> &leaves, std::vector<G3::BATCH> &batches, const G3::VEC3F &pos) const;

        /**
            @brief Removes the node
        */
        int upload_removal (const std::vector<G3::OCT_NODE> &nodes, const std::vector<G3::OCT_LEAF> &leaves, std::vector<G3::BATCH> &batches) const;
};

}

#endif // G3_OCT_NODE_H
